package io.lhj.chapter03;

import java.util.concurrent.TimeUnit;

public class ThreadisInterrupted {

    public static void main(String[] args) throws InterruptedException
    {
        Thread thread = new Thread()
        {
            @Override
            public void run()
            {
                Thread thread = new Thread(){
                    @Override
                    public void run()
                    {
                        while (true)
                        {
//do nothing, just empty loop.
                            System.out.println("empty loop");
                        }
                    }
                };
                thread.setDaemon(true);
                thread.start();
                try {
                    TimeUnit.MILLISECONDS.sleep(2000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }

            }
        };
        thread.start();

        TimeUnit.MINUTES.sleep(1);
//        TimeUnit.MILLISECONDS.sleep(2);
//        System.out.printf("Thread is interrupted ? %s\n", thread.isInterrupted());
//        thread.interrupt();
//        System.out.printf("Thread is interrupted ? %s\n", thread.isInterrupted());
    }
}
